<template>
	<view style="padding-bottom: 120rpx;">
		<view class="header">
			<u-swiper :list="shopInfo.images" height='500' mode='number' indicator-pos='bottomRight'></u-swiper>
			<view class="nav-bar">
				<view class="left" @click="back">
					<image src="../../../../static/imgs/backicon.png" mode=""></image>
				</view>
				<view class="right" @click="showShare=true">
					<image src="../../../../static/imgs/fengxiangbg.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="shopInfo">
			<image :src="shopInfo.icon" mode=""></image>
			<view class="info">
				<view class="name">
					{{shopInfo.shop_name}}
				</view>
				<view class="rate">
					<u-icon name="star-fill" color="#FE8C16" size="28"></u-icon>
					<text>{{shopInfo.score}}分</text>
				</view>
				<view class="price">
					¥ {{shopInfo.average_cost}}/人
				</view>
				<view class="address" @click="toMapAPP(shopInfo.latitude,shopInfo.longitude,shopInfo.address)">
					<text>{{shopInfo.city+'市'+shopInfo.district+'区'+ shopInfo.address}}</text>
					<u-icon name="arrow-right" color="#666666" size="24"></u-icon>
				</view>
			</view>
		</view>
		<view class="busyInfo">
			<view class="status">
				营业中
			</view>
			<view class="date">
				{{busyWeek}} {{busyTIme}}
			</view>
			<view class="tips">
				<view class="tips-li" v-for="(tip,tipx) in shopInfo.tags_name" :key='tipx'>
					{{tip}}
				</view>
			</view>
		</view>
		<view class="tabs">
			<u-tabs ref="uTabs" :list="tabList" :current="current" @change="tabsChange" bar-width='64' bar-height="10"
				inactive-color='#333333' bg-color='#f2f2f2' :bar-style='barStyle' :active-item-style='itemStyle'
				:is-scroll="false"></u-tabs>
		</view>
		<view class="content" v-if="current == 0">
			<view class="goods-ul" v-if="goodsList.length">
				<view class="goods-li" v-for="(goods,index) in goodsList" :key='index'>
					<image :src="goods.icon" mode=""></image>
					<view class="info">
						<view class="title">
							{{goods.title}}
						</view>
						<view class="price">
							<text style="font-size: 24rpx;">¥</text> {{goods.price}}
						</view>
					</view>
				</view>
			</view>
			<view style="padding: 20rpx;" v-else>
				暂无商品
			</view>
		</view>
		<view class="content" v-if="current == 1">
			<view class="comment-ul">
				<view class="comment-li">
					<view class="user">
						<image src="../../../../static/imgs/del/del1.png" mode=""></image>
						<view class="info">
							<view class="name">
								执泥
							</view>
							<view class="date">
								2021-1-8 15：28
							</view>
						</view>
					</view>
					<view class="rate">
						<text>评分：</text>
						<u-icon name="star-fill" color="#FE8C16" size="28"></u-icon>
						<text style="color: #FE8C16;">4.7分</text>
					</view>
					<view class="comment">
						这婚纱好闪耀呀，是我想要的那种奢华感，大气。一收到货，迫不及待的就试穿了，根本舍不得脱下来，效果真的是好，公主式的泡泡袖正好挡住我的拜拜肉。领口呈v型，显瘦，店家的婚纱真是物美价廉
					</view>
				</view>
			</view>
		</view>
		<view class="content" v-if="current == 2">
			<view class="intro">
				<view class="title">
					{{shopInfo.shop_name}}
				</view>
				<view class="introText">
					{{shopInfo.content}}
				</view>
			</view>
		</view>
		<view class="guessLike">
			<view class="title">
				<image src="../../../../static/imgs/left.png" mode=""></image>
				<text class="text">猜你喜欢</text>
				<image src="../../../../static/imgs/right.png" mode=""></image>
			</view>
		</view>
<!-- 		<view class="guessLikeShop">
			<u-waterfall v-model="flowList">
				<template v-slot:left="{leftList}">
					<view class="storeItem" v-for="(item, index) in leftList" :key="index"
						@click="navTo('./shop/shop')">
						<image src="../../../../static/imgs/del/del.png" mode=""></image>
						<view class="title">
							大易经典文化传播中心
						</view>
						<view class="rate">
							<u-icon name="star-fill" color="#FE8C16" size="28"></u-icon>
							<text>4.7分</text>
						</view>
						<view class="price">
							¥ 88/人
						</view>
						<view class="address">
							福田区鸿福路37号1256a···
						</view>
					</view>
				</template>
				<template v-slot:right="{rightList}">
					<view class="storeItem" v-for="(item, index) in rightList" :key="index"
						@click="navTo('./shop/shop')">
						<image src="../../../../static/imgs/del/del.png" mode=""></image>
						<view class="title">
							大易经典文化传播中心大易经典文化传播中心
						</view>
						<view class="rate">
							<u-icon name="star-fill" color="#FE8C16" size="28"></u-icon>
							<text>4.7分</text>
						</view>
						<view class="price">
							¥ 88/人
						</view>
						<view class="address">
							福田区鸿福路37号福田区鸿福路37号
						</view>
					</view>
				</template>
			</u-waterfall>
		</view> -->
		<view class="buy-btn">
			<view class="btn" @click="navTo('../pay/pay?shopId='+shopId)">
				立即支付
			</view>
		</view>
		<u-popup v-model="showShare" mode="bottom" border-radius="16" :closeable='true'>
			<view class="sharePop">
				<view class="title">
					分享到
				</view>
				<view class="share-ul">
					<view class="share-li">
						<image src="../../../../static/imgs/weixinhy.png" mode=""></image>
						<text>微信好友</text>
					</view>
					<view class="share-li">
						<image src="../../../../static/imgs/shengchengkp.png" mode=""></image>
						<text>生成卡片</text>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import myRequest from '@/api/index.js'
	export default {
		data() {
			return {
				shopId: '',
				showShare: false,
				flowList: [1, 2],
				barStyle: {
					background: 'linear-gradient(180deg, #93B9F9 0%, #2D7AFE 100%)',
					borderRadius: '40rpx',
				},
				itemStyle: {
					fontSize: '34rpx',
					fontWeight: 'bold',
					color: '#333333'
				},
				current: 0,
				tabList: [{
						name: '商品'
					},
					{
						name: '评价'
					},
					{
						name: '商家信息'
					}
				],
				list: [
					'../../../../static/imgs/del/del1.png',
					'../../../../static/imgs/del/del1.png',
					'../../../../static/imgs/del/del1.png'
				],
				background: {
					background: 'rgba(255,255,255,0)'
				},
				shopInfo: '', //门店信息
				busyTIme: '',
				busyWeek: '',
				goodsList: []

			}
		},
		onLoad(option) {
			this.shopId = option.id
			this.getDetail()
			this.getGoods()
		},
		methods: {
			toMapAPP(latitude, longitude, name) {
				let url = "";
				if (plus.os.name == "Android") { //判断是安卓端
					plus.nativeUI.actionSheet({ //选择菜单
						title: "选择地图应用",
						cancel: "取消",
						buttons: [{
							title: "百度地图"
						}, {
							title: "高德地图"
						}],
					}, function(e) {
						switch (e.index) {
							case 1:
								url =
									`baidumap://map/marker?location=${latitude},${longitude}&title=${name}&coord_type=gcj02&src=andr.baidu.openAPIdemo`;
								break;
							case 2:
								url =
									`androidamap://viewMap?sourceApplication=appname&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
								break;
							default:
								break;
						}
						if (url != "") {
							url = encodeURI(url);
							plus.runtime.openURL(url, function(e) {
								plus.nativeUI.alert("未安装应用");
							});
						}
					})
				} else {
					plus.nativeUI.actionSheet({
						title: "选择地图应用",
						cancel: "取消",
						buttons: [{
							title: "百度地图"
						}, {
							title: "高德地图"
						}]
					}, function(e) {
						switch (e.index) {
							case 1:
								url =
									`baidumap://map/marker?location=${latitude},${longitude}&title=${name}&content=${name}&src=ios.baidu.openAPIdemo&coord_type=gcj02`;
								break;
							case 2:
								url =
									`iosamap://viewMap?sourceApplication=applicationName&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
								break;
							default:
								break;
						}
						if (url != "") {
							url = encodeURI(url);
							plus.runtime.openURL(url, function(e) {
								plus.nativeUI.alert("未安装应用");
							});
						}
					})
				}
			},
			// 门店商品
			async getGoods(){
				let {
					shopId,
				} = this
				let res =await myRequest.getShopgoods({
					page:'1',
					shop_id:shopId
				})
				if(res.status){
					this.goodsList = res.data
				}
			},
			// 门店详情
			async getDetail() {
				let {
					shopId,
				} = this
				let res = await myRequest.getShopdetail({
					page: '1',
					shop_id: shopId
				})
				if (res.status) {
					this.shopInfo = res.data
					this.busyTIme = res.data.business_hours[0].start_time + '-' + res.data.business_hours[0].end_time
					this.busyWeek = res.data.business_hours[0].type_name
				}
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				})
			},
			tabsChange(index) {
				this.current = index
			}
		}
	}
</script>

<style lang="scss" scoped>
	.header {
		width: 100%;
		height: 500rpx;

		.nav-bar {
			width: 100%;
			height: 88rpx;
			padding: 0 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			position: absolute;
			// #ifdef APP-PLUS
			top: var(--status-bar-height);
			// #endif
			// #ifdef H5
			top: 0;

			// #endif
			.left,
			.right {
				image {
					width: 60rpx;
					height: 60rpx;
				}
			}
		}
	}

	.shopInfo {
		width: 710rpx;
		height: 210rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin: -105rpx auto;
		position: relative;
		display: flex;
		align-items: center;
		padding-left: 28rpx;

		image {
			width: 160rpx;
			height: 160rpx;
		}

		.info {
			margin-left: 20rpx;
			width: 70%;
			.name {
				font-size: 28rpx;
				font-family: Segoe UI;
				font-weight: bold;
				color: #333333;
			}

			.rate {
				margin-top: 8rpx;
				font-size: 24rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #FE8C16;
			}

			.price {
				margin-top: 8rpx;
				font-size: 26rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #999999;
			}

			.address {
				margin-top: 12rpx;
				font-size: 24rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #666666;
			}
		}
	}

	.busyInfo {
		width: 710rpx;
		height: auto;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin: 128rpx auto 0;
		padding-left: 28rpx;
		padding-top: 18rpx;
		padding-bottom: 18rpx;

		.status {
			font-size: 28rpx;
			font-family: Segoe UI;
			font-weight: bold;
			color: #333333;
		}

		.date {
			margin-top: 18rpx;
			font-size: 28rpx;
			font-family: SFProText-Semibold;
			color: #999999;
		}

		.tips {
			display: flex;
			margin-top: 14rpx;

			.tips-li {
				width: fit-content;
				width: -webkit-fit-content;
				width: -moz-fit-content;
				height: 40rpx;
				border: 2rpx solid #D4E3FC;
				border-radius: 40rpx;
				font-size: 24rpx;
				font-family: SFProText-Semibold;
				color: #999999;
				padding: 0 10rpx;
				margin-right: 20rpx;

				&:last-child {
					margin-right: 0rpx;
				}
			}
		}
	}

	.tabs {
		margin-top: 20rpx;
		width: 60%;
	}

	.content {
		width: 710rpx;
		height: auto;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin: 10rpx auto 0;

		.goods-ul {
			padding: 20rpx;

			.goods-li {
				display: flex;
				align-items: center;
				margin-bottom: 20rpx;

				&:last-child {
					margin-bottom: 0;
				}

				image {
					width: 160rpx;
					height: 160rpx;
				}

				.info {
					margin-left: 20rpx;
					width: 75%;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.title {
						font-size: 28rpx;
						font-family: Segoe UI;
						font-weight: 400;
						color: #333333;
					}

					.price {
						margin-top: 40rpx;
						font-size: 34rpx;
						font-family: Segoe UI;
						font-weight: 400;
						color: #FE8C16;
					}
				}
			}
		}

		.comment-ul {
			padding: 20rpx;

			.comment-li {
				margin-bottom: 30rpx;

				&:last-child {
					margin-bottom: 0rpx;
				}

				.user {
					display: flex;

					image {
						width: 84rpx;
						height: 84rpx;
						border-radius: 50%;
					}

					.info {
						margin-left: 10rpx;

						.name {
							font-size: 28rpx;
							font-family: Segoe UI;
							font-weight: 400;
							color: #333333;
						}

						.date {
							margin-top: 8rpx;
							font-size: 24rpx;
							font-family: Segoe UI;
							font-weight: 400;
							color: #999999;
						}
					}
				}

				.rate {
					margin-top: 10rpx;
					font-size: 24rpx;
					font-family: Segoe UI;
					font-weight: 400;
					color: #999999;
				}

				.comment {
					margin-top: 10rpx;
					font-size: 28rpx;
					font-family: Segoe UI;
					font-weight: 400;
					color: #333333;
				}
			}
		}

		.intro {
			padding: 20rpx;

			.title {
				font-size: 28rpx;
				font-family: Segoe UI;
				font-weight: bold;
				color: #333333;
			}

			.introText {
				margin-top: 12rpx;
				font-size: 28rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #333333;
			}
		}
	}

	.guessLike {
		margin-top: 28rpx;

		.title {
			width: 694rpx;
			height: 88rpx;
			margin: 0 auto;
			display: flex;
			align-items: center;
			justify-content: center;

			image {
				width: 64rpx;
				height: 12rpx;
				vertical-align: middle;
			}

			.text {
				margin: 0 28rpx 8rpx;
				font-size: 32rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #333333;
			}
		}
	}

	.guessLikeShop {
		padding: 0 20rpx;

		.storeItem {
			width: 348rpx;
			height: auto;
			background: #FFFFFF;
			border-radius: 16rpx;
			padding-bottom: 18rpx;
			margin-bottom: 20rpx;

			image {
				width: 348rpx;
				height: 348rpx;
			}

			.title {
				padding: 0 10rpx;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #333333;
			}

			.rate {
				margin-top: 8rpx;
				padding-left: 10rpx;
				font-size: 24rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #FE8C16;

				text {
					margin-left: 8rpx;
				}
			}

			.price {
				margin-top: 8rpx;
				padding-left: 10rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #333333;
			}

			.address {
				margin-top: 10rpx;
				padding: 0 10rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #999999;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}
		}
	}

	.buy-btn {
		width: 100%;
		height: 120rpx;
		background: #F2F2F2;
		position: fixed;
		bottom: 0;
		padding: 20rpx 0;

		.btn {
			width: 660rpx;
			height: 80rpx;
			background: linear-gradient(180deg, #218BFF 0%, #3064FC 100%);
			border-radius: 16rpx;
			margin: 0 auto;
			font-size: 34rpx;
			font-family: Segoe UI;
			font-weight: 400;
			line-height: 80rpx;
			color: #FFFFFF;
			text-align: center;
		}
	}

	.sharePop {
		padding: 0 28rpx;

		.title {
			width: 100%;
			height: 100rpx;
			text-align: center;
			line-height: 100rpx;
			font-size: 34rpx;
			font-family: Segoe UI;
			font-weight: 400;
			color: #333333;
			border-bottom: 2rpx solid #F2F2F2;
		}

		.share-ul {
			width: 100%;
			height: 240rpx;
			display: flex;
			align-items: center;

			.share-li {
				flex: 1;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				image {
					width: 88rpx;
					height: 88rpx;
				}

				text {
					margin-top: 20rpx;
					font-size: 28rpx;
					font-family: Segoe UI;
					font-weight: 400;
					color: #333333;
				}
			}
		}
	}

	/deep/ .u-swiper-indicator {
		bottom: 120rpx !important;
	}

	.shareIcon {
		width: 48rpx;
		height: 48rpx;
	}
</style>
